package 多线程;

/**
 * @Author zhang lei
 * @Date 2021-12-23 14:59
 */
public class MultiTest {
    public static void main(String[] args) {
        Ticket t = new Ticket();

        new Thread(t, "线程1").start();
        new Thread(t, "线程2").start();
        new Thread(t, "线程3").start();
    }
}

class Ticket implements Runnable{

    private int num = 100;

    private boolean flag = true;

    @Override
    public void run() {
        while (flag) {
            num--;
            System.out.println("。。。。。卖出一张票，剩余"+num+", Name"+Thread.currentThread().getName());
            if(num<=0) {
                flag = false;
            }
        }
    }
}
